package cn.iocoder.devlop.module.annual.report.sfcbranchinfo.controller.app;

import cn.iocoder.devlop.framework.common.pojo.CommonResult;
import cn.iocoder.devlop.module.annual.report.sfcbranchinfo.controller.vo.SfcBranchinfoOverwriteVO;
import cn.iocoder.devlop.module.annual.report.sfcbranchinfo.controller.vo.SfcBranchinfoRespVO;
import cn.iocoder.devlop.module.annual.report.sfcbranchinfo.convert.SfcBranchinfoConvert;
import cn.iocoder.devlop.module.annual.report.sfcbranchinfo.dal.dataobject.SfcBranchinfoDO;
import cn.iocoder.devlop.module.annual.report.sfcbranchinfo.service.SfcBranchinfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.devlop.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 年报农合分支机构信息")
@RestController
@RequestMapping("/annual/report/sfc-branchinfo")
@Validated
public class AppSfcBranchinfoController {

    @Resource
    private SfcBranchinfoService sfcBranchinfoService;

    @GetMapping("/list")
    @Operation(summary = "获得年报股权变更信息列表")
    public CommonResult<List<SfcBranchinfoRespVO>> getSfcBranchinfoList(@RequestParam("regno") String regno, @RequestParam("ancheyear") String ancheyear) {
        List<SfcBranchinfoDO> list = sfcBranchinfoService.getSfcBranchinfoList(regno, ancheyear);
        return success(SfcBranchinfoConvert.INSTANCE.convertList(list));
    }

    @PutMapping("/overwrite")
    @Operation(summary = "覆盖更新年报股权变更信息列表")
    public CommonResult<Boolean> overwriteSfcBranchinfo(@Valid @RequestBody SfcBranchinfoOverwriteVO updateReqVO) {
        sfcBranchinfoService.overwriteSfcBranchinfo(updateReqVO);
        return success(true);
    }

}
